package controleImpl;

import java.awt.Color;

import interfaceGrafica.GUI;
import controleInterface.ArrivalSensorInterface;

public class ArrivalSensorImpl implements ArrivalSensorInterface {

	private int currentFloor;

	private int e;

	public ArrivalSensorImpl(int elev){
		this.e = elev;
	}

	public int getCurrentFloor() {
		return currentFloor;
	}

	public void setCurrentFloor(int elevator, int currentFloor) {
		this.currentFloor = currentFloor;
		if (elevator == 1){
			GUI.v().updatePositionElevator1(currentFloor);	
		}
		else{
			GUI.v().updatePositionElevator2(currentFloor);
		}

	}

	public void run() {
		try {
			for (;;){
				if (e == 1){
					GUI.v().LblSensorElevator1(Color.GREEN);
					Thread.sleep(1000);
					activeSensor(1);	
					Thread.sleep(1000);
				}
				else{
					GUI.v().LblSensorElevator2(Color.GREEN);
					Thread.sleep(1000);
					activeSensor(2);	
					Thread.sleep(1000);
				}
			}
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}

	public void activeSensor(int elevator){
		if (elevator == 1){
			GUI.v().LblSensorElevator1(Color.RED);
		}
		else{
			GUI.v().LblSensorElevator2(Color.RED);
		}
		//setar labels pra verde
		//verificar qual andar estar clicado
		//atualizar o currentFloor em Controller
		//setar os labels pra vermelho
	}
}
